# -*- coding:utf-8 -*-
"""
@Time : 2022/4/23 8:33 PM
@Author: binkuolo
@Des: views home
"""
from fastapi import Request, APIRouter,Cookie
from fastapi.responses import HTMLResponse
# from fastapi.templating import Jinja2Templates
from config import settings
from typing import Optional

router = APIRouter()

# templates = Jinja2Templates(directory=settings.TEMPLATE_DIR)
@router.get("/item/{id}", tags=["门户首页"], response_class=HTMLResponse)
async def home(request: Request,session_id:Optional[str] = Cookie(None)):
    cookie = session_id
    session = request.session.get("session")
    page_data = {
        "cookie":cookie,
        "session":session
    }
    # return templates.TemplateResponse("index.html",{"request":request,"id":id})
    return request.app.state.views.TemplateResponse("index.html", {"request": request,**page_data})
# async def home(request: Request,id:str):
#     """
#     门户首页
#     :param request:
#     :return:
#     """
#     # return templates.TemplateResponse("index.html",{"request":request,"id":id})
#     return request.app.state.views.TemplateResponse("index.html", {"request": request,"id":id})
